package com.example.controller.sys;

import java.util.Arrays;

import com.example.vo.reqvo.CollectContactParams;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.vo.ResultVo;
import com.github.pagehelper.PageInfo;
import com.example.pojo.ContactsGroupDetail;
import com.example.service.IContactsGroupDetailService;
import io.swagger.annotations.Api;
/**
 * <p>
 * 联系人分组详情表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-05-14
 */
@RestController
@RequestMapping("/sys/contacts-group-detail")
@Api(tags = "联系人分组详情表",value = "")
@CrossOrigin(allowCredentials = "true")
public class ContactsGroupDetailController {

    @Autowired
    private IContactsGroupDetailService contactsGroupDetailService;

    @ApiOperation(value = "查询联系人分组详情表")
    @GetMapping("/query")
    public ResultVo getContactsGroupDetailPageInfo(Integer empId) {
        return contactsGroupDetailService.getContactsGroupDetailPageInfo(empId);
    }

    @ApiOperation(value = "新增联系人分组详情表")
    @PostMapping("/add")
    public ResultVo addContactsGroupDetail(@RequestBody CollectContactParams collectContactParams) {
        return contactsGroupDetailService.insertContactsGroupDetail(collectContactParams);
    }

//    @ApiOperation(value = "修改联系人分组详情表")
//    @PutMapping("/update")
//    public ResultVo updateContactsGroupDetail(@RequestBody ContactsGroupDetail contactsGroupDetail) {
//        if (contactsGroupDetailService.updateById(contactsGroupDetail)) {
//            return ResultVo.success("修改成功。");
//        }
//        return ResultVo.error("修改失败!");
//    }

    @ApiOperation(value = "删除收藏组联系方式")
    @DeleteMapping("/delete")
    public ResultVo deleteContactsGroupDetail(Integer[] ids){
        if(contactsGroupDetailService.removeByIds(Arrays.asList(ids))){
            return ResultVo.ok();
        }
        return ResultVo.error();
    }

    @ApiModelProperty(value = "查询已经加入的群组")
    @GetMapping("/joined-group")
    public ResultVo queryJoinedGroup(@RequestParam("empId") Integer empId,@RequestParam("targetEmpId") Integer targetEmpId){
        return contactsGroupDetailService.getJoinedGroup(empId,targetEmpId);
    }
}
